package cn.edu.ren.controller;

import cn.edu.ren.pojo.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

/**
 * @PackageName: cn.edu.ren.controller
 * @ClassName: Swagger2Controller
 * @Description:
 * @author: RZS
 * @date: 2021/5/26  17:33
 */
@RestController
@RequestMapping("/swagger2")
@Api(tags = "swagger2测接口")
public class Swagger2Controller {

    @PostMapping("/add_user")
    @ApiOperation("添加用户的接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "username", value = "用户名", defaultValue = "李四"),
            @ApiImplicitParam(name = "address", value = "用户地址", defaultValue = "深圳", required = true)
    }
    )
    public String addUser(String username, @RequestParam(required = true) String address) {
        return "Hello Swagger2";
    }

    @GetMapping("/sel_by_id_user")
    @ApiOperation("根据id查询用户的接口")
    @ApiImplicitParam(name = "id", value = "用户id", defaultValue = "99", required = true)
    public User getUserById(@PathVariable Integer id) {
        User user = new User();
        user.setId(id);
        return user;
    }

    @PutMapping("/update/{id}")
    @ApiOperation("根据id更新用户的接口")
    public User updateUserById(@RequestBody User user) {
        return user;
    }
}
